﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="pinmap.aspx.cs" Inherits="WebUI.pinmap" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">


    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">

    var locationCurrent = null;
    window.onload = function () {
        var mapOptions = {
            center: new google.maps.LatLng(21.0000, 78.0000),
            zoom: 5,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);

        //Attach click event handler to the map.
        google.maps.event.addListener(map, 'click', function (e) {
            debugger;
            //Determine the location where the user has clicked.
            var location = e.latLng;

            locationCurrent =e.latLng;
           // btn.disabled = false;
            //Create a marker and placed it on the map.
            var marker = new google.maps.Marker({
                position: location,
                map: map
            });

            
            document.getElementById('<%= hdX.ClientID%>').value = locationCurrent.lat();
            document.getElementById('<%= hdY.ClientID%>').value = locationCurrent.lng();

            //Attach click event handler to the marker.
            google.maps.event.addListener(marker, "click", function (e) {
                var infoWindow = new google.maps.InfoWindow({
                    content: 'Latitude: ' + location.lat() + '<br />Longitude: ' + location.lng()
                });
                infoWindow.open(map, marker);
            });
        });
    };


    function GetLocation()
    {
        //var infoWindow = new google.maps.InfoWindow({
        //    content: 'Latitude: ' + location.lat() + '<br />Longitude: ' + location.lng()
        //});
        hdX.Value = locationCurrent.lat();
        hdY.Value = locationCurrent.lng();


        alert(locationCurrent.lat() + " and " + locationCurrent.lng());

    }


  

</script>




    <div id="geodir_bathroom_count_row2" class="  geodir_form_row clearfix">
                          <div id="dvMap" style="width: 500px; height: 500px;margin-left :200px;margin-top:110px;" ></div>
                    </div>
   
         <div id="geodir_bathroom_count_row1" class="  geodir_form_row clearfix">
                         <asp:Button ID="btPinMap" runat="server" Text="PinMap" OnClick="btPinMap_Click" margin-left="200px" CssClass="geodir_button wpb_button wpb_btn-warning wpb_regularsize" />
                    </div>


    <asp:HiddenField ID="hdX" runat ="server"  />
      <asp:HiddenField ID="hdY" runat ="server"  />

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FooterContent" runat="server">
</asp:Content>
